package com.youchuang.interceptor;

import java.util.Map;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import com.youchuang.bean.User;
import com.youchuang.common.Constant;

@SuppressWarnings("serial")
public class LoginInterceptor extends AbstractInterceptor {

	public String intercept(ActionInvocation invocation) throws Exception {
		Map<String, Object> session = invocation.getInvocationContext().getSession();
		if (session.get(Constant.S_USER) == null) {
			return Constant.LOGIN;
		}
		if (((User) session.get(Constant.S_USER)).getEmailVerify() == Constant.NOT_PASS) {
			return Constant.LOGIN;
		}
		return invocation.invoke();
	}
}
